#!/usr/bin/perl

use Imager;

my $img = Imager->new;

#$img->read( file => 'sample.jpg' )
$img->read( file => 'shizucha.jpg' );

#$img->read( file => 'syouko.jpg' )
or die $img->errstr;

$img->rubthrough(
    src => do {
        my $tmp = Imager->new;
#        $tmp->read( file => 'smoke_toka.png' ) or die $tmp->errstr;
        $tmp->read( file => 'smoke.png' ) or die $tmp->errstr;

        $tmp = $tmp->convert(matrix =>[ [ 1, 0, 0, 0 ],
                                 [ 0, 1, 0, 0 ],
                                 [ 0, 0, 1, 0 ],
                                 [ 0, 0, 0, 0.6 ],
                             ]);

        $tmp; # srcへふきだし画像のImagerオブジェクトを渡す
    },
    tx => -100,
    ty => 0,
);


#left > x:221 y:57
#right > x:173 y:57
#left > x:89 y:70
#right > x:51 y:70

$img->box(
    xmin =>  163, ymin => 47,
    xmax => 241, ymax => 67,
    color => '#000000',
    filled => 1,
);

$img->box(
    xmin => 41, ymin => 60,
    xmax => 119, ymax => 80,
    color => '#000000',
    filled => 1,
);


$img->write( file => 'xxx.jpg', jpegquality => 100 )
or die $img->errstr;
